
(function () {
	jtool.marque = {start:function (displayULID, contentULID, initNum, dynamicContentCaller) {
		var dul = $("#" + displayULID);
		var cul = $("#" + contentULID);
		var clis = $("#" + contentULID + " > li");
		try {
			for (var i = 0; i < initNum; i++) {
				var cli = clis[i];
				cli = $(cli);
				cli.remove();
				cli.clone().appendTo(dul);
				if (dynamicContentCaller == null) {
					cli.appendTo(cul);
				}
			}
		}
		catch (e) {
		}
		var suspend = false;
		window.setInterval(function () {
			if (!suspend) {
				suspend = true;
				var dli = $("#" + displayULID + " > li")[0];
				$(dli).remove();
				var cli = $("#" + contentULID + " > li")[0];
				cli = $(cli);
				cli.remove();
				var dli = cli.clone();
				dli.hover(function () {
					suspend = true;
				}, function () {
					suspend = false;
				});
				if (dynamicContentCaller != null) {
					cli.html(dynamicContentCaller());
				}
				dli.appendTo(dul);
				cli.appendTo(cul);
				suspend = false;
			}
		}, 10000);
	}, loopReplaceContent:function (displayULID, contentULID, initNum, dynamicContentCaller) {
		var dul = $("#" + displayULID);
		var cul = $("#" + contentULID);
		var clis = $("#" + contentULID + " > li");
		var suspend = false;
		var enoughToLoop = true;
		try {
			for (var i = 0; i < initNum; i++) {
				var cli = clis[i];
				if (!cli) {
					break;
					enoughToLoop = false;
				}
				cli = $(cli);
				cli.remove();
				var newLi = cli.clone();
				newLi.appendTo(dul);
				newLi.hover(function () {
					suspend = true;
				}, function () {
					suspend = false;
				});
				if (dynamicContentCaller == null) {
					cli.appendTo(cul);
				}
			}
		}
		catch (e) {
		}
		if (enoughToLoop || dynamicContentCaller) {
			var currentReplaceIndex = 0;
			window.setInterval(function () {
				try {
					if (!suspend) {
						var dli = $("#" + displayULID + " > li")[currentReplaceIndex];
						var cli = $("#" + contentULID + " > li")[0];
						cli = $(cli);
						dli = $(dli);
						var newli = cli.clone();
						dli.after(newli).remove();
						newLi.hover(function () {
							suspend = true;
						}, function () {
							suspend = false;
						});
						if (dynamicContentCaller != null) {
							suspend = true;
							dynamicContentCaller(cli);
							suspend = false;
						}
						cli.remove();
						cli.appendTo(cul);
						currentReplaceIndex = currentReplaceIndex + 1;
						if (currentReplaceIndex >= initNum) {
							currentReplaceIndex = 0;
						}
					}
				}
				catch (e) {
				}
			}, 10000);
		}
	}};
})();

